#include "ProcessPool.hpp"
#include "Task.hpp"
#include <iostream>


////////////////debug/////////////////////
void PrintLog()
{
    std::cout << "我是一个打印日志的任务" << std::endl;
}

void Download()
{
    std::cout << "我是一个下载的任务" << std::endl;
}

void Upload()
{
    std::cout << "我是一个上传的任务" << std::endl;
}
///////////////////////////////////////////






int main()
{

    vector<task_func> tasks({PrintLog, Download, Upload});

    //1.初始化进程池(向任务列表中添加任务, 再创建多个信道)
    process_pool pp;
    pp.init(5, tasks);//添加任务要在fork之前, 这样子进程才能继承父进程的task_list 

    // //2.添加任务
    // cout << "添加任务: " << "PrintLog, 任务码: " << pp.add_task(PrintLog) << endl;
    // cout << "添加任务: " << "Download, 任务码: " << pp.add_task(Download) << endl;
    // cout << "添加任务: " << "Upload, 任务码: " << pp.add_task(Upload) << endl;



    //3.运行进程池
    pp.run();

    //4.关闭进程池
    pp.quit();


    return 0;
}